<?php include $this->admin_tpl('meta', 'admin');?>
<title>添加微信场景 - YzmCMS内容管理系统</title>
</head>
<style>
.exp{margin:5px 0px 5px 120px;color:#888}
</style>
<body>
<article class="page-container">
<div class="formdoby_normal"> 
	<form method="post" onsubmit="return dosub(this)">
		<ul>
			<li><label><span class="c-red">*</span>场景ID：</label>
				<input type="text" class="input" style="width:300px" name="scan" value="">
				<p class="exp">场景ID必须为英文、数字或下划线，且长度为1-30位。</p>
			</li>
			<li><label>场景分类：</label>
				<label><input class="radio" type="radio" name="type" value="1" checked="checked"> 临时二维码</label>
	            <label><input class="radio" type="radio" name="type" value="0" > 永久二维码</label>	
	        </li>
			<li id="expire_time"><label>过期时间：</label>
				<select  name="expire_time" class="select" style="width:300px">
					<option value="180">3分钟</option>
					<option value="1800">30分钟</option>
					<option value="3600">1小时</option>
					<option value="10800">3小时</option>
					<option value="21600">6小时</option>
					<option value="43200">12小时</option>
					<option value="86400">24小时</option>
				</select>
			</li>
			<li><label>备注：</label>
				<textarea class="textarea" name="remarks" style="width:450px"></textarea>
			</li>
		</ul>
		<div class="footer_btn">
			<input type="hidden" name="dosubmit" value="1">
			<input class="btn btn-primary radius" type="submit" value="提 交">
			<input class="btn btn-default radius" type="button" value="取 消" onclick="yzmcms_close()">	
		</div>
	</form>
</div>
</article>
<?php include $this->admin_tpl('footer', 'admin');?>

<script type="text/javascript">
	$(function(){
		$('input:radio[name="type"]').change(function(){  
			if($(this).val()=='1') {
				$('#expire_time').css('display','');
			}else{
				$('#expire_time').css('display','none');
			}
		}); 
	});

	function dosub(obj){
		 var reg = /^[a-zA-Z]{1}([a-zA-Z0-9]|[_]){0,29}$/;	
		 if(obj.scan.value.length<1 || obj.scan.value.length>30){
		 	layer.msg('场景ID长度必须为1-30位！', {icon:2});
		 	return false;
		 }
		 if(!reg.test(obj.scan.value)){
		 	layer.msg('场景ID必须为英文、数字或下划线！', {icon:2});
		 	return false;
		 }
        $.ajax({
            type: 'POST',
            url: '<?php echo U('add');?>', 
            data: $(obj).serialize(),
		    dataType: "json", 
            success: function (msg) {
				if(msg.status == 1){
					layer.msg(msg.message, {icon:1,time:1500}, function(){
						parent.location.reload();     
					});
			    }else{
					layer.msg(msg.message, {icon:2});
				}
            }
        })		 
		return false;			 
	}
</script> 

</body>
</html>